﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace CrackNET.WpfTestApp
{
    public partial class Window1 : Window
    {
        public Window1 _window1 = null;

        public static MyObservableType _observableObject = new MyObservableType();

        static Window1()
        {
            _observableObject.PropertyChanged += new Window1()._observableObject_PropertyChanged;
            _observableObject.PropertyChanged += new Window1()._observableObject_PropertyChanged;
            _observableObject.PropertyChanged += new Window1()._observableObject_PropertyChanged;
        }

        void _observableObject_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {            
        }

        public Window1()
        {
            InitializeComponent();

            this.Loaded += delegate
            {
                CrackNET.InjectedViewer.EntryPoint.InjectedMain();

                Border parentBorder = this.borderRoot;
                for (int i = 0; i < 52; ++i)
                {
                    Border bd = new Border 
                    { 
                        Background = Brushes.White,
                        BorderBrush = (i % 2 == 0) ? Brushes.Black : Brushes.White,
                        BorderThickness = new Thickness(1)
                    };
                    parentBorder.Child = bd;
                    parentBorder = bd;
                }
            };

            this.MouseDown += new System.Windows.Input.MouseButtonEventHandler(Window1_MouseDown);
        }

        void Window1_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Debug.WriteLine("(C#) Mouse Down @ " + e.GetPosition(this));
        }

        public class MyObservableType : INotifyPropertyChanged
        {
            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged = delegate { };

            #endregion
        }


        public static bool AnotherProperty { get; set; }

        public static Window[] _arrayOfWindow;
        public static Window[,] _arrayOfArrayOfWindow;

        public static Int32[] _arrayOfInt32;
        public static Int32[,] _arrayOfArrayOfInt32;
        public static Int32[,,] _arrayOfArrayOfArrayOfInt32;

        public static Double[][] _jaggedArrayOfDouble;
        public static Button[][][] _jaggedArrayOfArrayOfButton;

        public static ObservableCollection<Uri> MyObservableField = new ObservableCollection<Uri>();

        public class SomeNestedType<T1, T2>
        {
            public class SomeNestedNestedType<T3>
            {
                public static List<Action<Func<T2, T3>, Action<T1>, OtherNamespace.MyType<T1>.MyGenericNestedType<String, bool, Action<T2>>>> MyCrazyTypeProperty { get; set; }
            }
        }

        public static Action<object, Button, Window> MyAction;

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Thanks, I appreciate the click.", "Well Done!");
        }
    }
}

namespace OtherNamespace
{
    public class MyType<TFoo>
    {
        public static readonly string Foo = "Foo!";

        internal struct MyNestedNestedType { public static string FooStr = "asdf"; }

        public class MyGenericNestedType<T1, T2, T3>
        {
            public static string FooString;

            public class MyNestedGenericNestedType<T4>
            {
                public static int FooInt = 42;
            }
        }
    }
}